<template>
	<gui-page>
		<template v-slot:gBody>
			<view 
			class="gui-bg-white gui-dark-bg-level-3 gui-padding gui-margin-top">
				<view v-for="(item, index) in items">
					<cardBody :icon="'&#xe692;'" :title="`${item.title}`" :value="`${item.value}`"></cardBody>
				</view>
			</view>
		</template>
	</gui-page>
</template>

<script setup>
	import { ref,getCurrentInstance,createApp } from 'vue'
	import { onLoad,onPullDownRefresh } from '@dcloudio/uni-app'
	import cardBody from "@/lib/components/card-body.vue"
	import guiPage from "@/Grace6/components/gui-page.vue"
	import ybmethod from '../../lib/js/ybmethod';
	import ybgolbal from '../../lib/js/ybgolbal';
	const app = createApp();
	const ybapi = ybgolbal.getybapi(getCurrentInstance());
	let id = ref('');
	let sj = ref('');
	let jzsj = ref('');
	let item = ref({});
	let items = ref([]);
	onLoad((option)=>{
		console.log("进入设备节电节能详情页面");
		console.log(option);
		id.value = option.id;
		getData();
	})
	onPullDownRefresh(()=>{
		ybmethod.onPullDownRefresh(getData);
	})
	function getData(){
		ybapi.Devices_GetJNInfoByid(id.value,function(data){
			console.log(data);
			item.value = data;
			sj.value = ybmethod.formatDateString(String(data.sj));
			jzsj.value = ybmethod.formatDateString(String(data.jzsj));
			setItems();
		},function(e){
			console.log(e);
		});
	}
	function setItems(){
		items.value.push({title: "序号",value: item.value.id});
		items.value.push({title: "设备id",value: item.value.devid});
		items.value.push({title: "日期时间",value: sj.value});
		items.value.push({title: "基准日期",value: jzsj.value});
		items.value.push({title: "基准有功电量KWH",value: item.value.jzygdl});
		items.value.push({title: "基准无功电量Kvar",value: item.value.jzwgdl});
		items.value.push({title: "基准总电流A", value: item.value.jzzdl});
		items.value.push({title: "当日有功电量KWH", value: item.value.curygdl});
		items.value.push({title: "当日无功电量Kvar",value: item.value.curwgdl});
		items.value.push({title: "当日平均总电流A",value: item.value.curzdl});
		items.value.push({title: "当日节电的有功电量KWH",value: item.value.jnygdl});
		items.value.push({title: "当日节电的无功电量Kvar",value: item.value.jnwgdl});
		items.value.push({title: "当日有功电量一天起始值KWH",value: item.value.curygdlstart});
		items.value.push({title: "当日无功电量一天起始值Kvar",value: item.value.curwgdlstart});
		items.value.push({title: "当日有功电量一天结束值KWH",value: item.value.curygdlend});
		items.value.push({title: "当日无功电量一天结束值Kvar",value: item.value.curwgdlend});
		items.value.push({title: "当天开始时间",value: item.value.curdaystart});
		items.value.push({title: "当天结束时间",value: item.value.curdayend});
	}
	app.component({
		cardBody,
		guiPage
	});
</script>

<style>
	       
</style>
